﻿<%@ Page Language="C#" %>

<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Collections" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="TarreOA.TarreOABLL" %>
<%@ Import Namespace="TarreOA.TarreOAModels  " %>

<script runat="server">

    private int cgid;
    
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            this.TxtBirthday.Attributes.Add("onfocus", "calendar()"); 
            User curLoginUser = (User)Session["user"];
            UserCommunicationGrouptbService ucgService = new UserCommunicationGrouptbService();
            List<UserCommunicationGrouptb> list = ucgService.findByUserLoginName(curLoginUser.LoginName);
            if (list != null && list.Count > 0)
            {
                foreach (UserCommunicationGrouptb ucg in list)
                {
                    this.DdlGroup.Items.Add(new ListItem(ucg.ComGroupName, ucg.ComGroupId.ToString()));
                } 
            }
            if (Request["cgid"] != null)
            {
                cgid = int.Parse(Request["cgid"]);
                ViewState["cgid"] = cgid;
            }    
        }
    }

    protected void BtnAppend_Click(object sender, EventArgs e)
    {
        if (ViewState["cgid"] != null)
        {
            cgid = (int)ViewState["cgid"]; 
        }  
        User curLoginUser = (User)Session["user"];
        string cgLinkManName = this.TxtName.Text;
        int comGroupId = int.Parse(this.DdlGroup.SelectedItem.Value);
        int cgLinkManSec = int.Parse(this.DropDownList2.SelectedItem.Value);
        DateTime cgLinkManBirthday = DateTime.Now; 
        if (!"".Equals(this.TxtBirthday.Text.Trim()))
        {
            try
            {
                cgLinkManBirthday = DateTime.Parse(this.TxtBirthday.Text);
            }
            catch
            {
                ScriptManager.RegisterClientScriptBlock(Page, GetType(), "", "alert('日期输入有错！');", true);
            }   
        }
        string cgLinkManName2 = this.TxtName2.Text;
        string cgLinkManDuty = this.TxtDuty.Text;
        string cgLinkManUnitName = this.TxtUnitName.Text;
        string cgLinkManUnitAddress = this.TxtUnitAddress.Text;
        string cgLinkManUnitTelephone = this.TxtUnitTelephone.Text;
        string cgLinkManUnitFacsimile = this.TxtUnitFacsimile.Text;
        string cgLinkManHomeAddress = this.TxtFamilyAddress.Text;
        string cgLinkManHomeTelephone = this.TxtFamilyTelephone.Text;
        string cgLinkManHandset = this.TxtHandset.Text;
        string cgLinkManEmail = this.TxtEmail.Text;
        string cgLinkManQicq = this.TxtOicq.Text;
        string cgLinkManMsn = this.TxtMSN.Text;
        string cgLinkManRemark = this.TxtRemark.Text;
        UserCommunicationGroupLinkMantbService ucgLinkMantbService = new UserCommunicationGroupLinkMantbService();
        ucgLinkMantbService.saveComGroupLinkManInfo(comGroupId, cgLinkManName, cgLinkManSec, cgLinkManBirthday, cgLinkManName2,
            cgLinkManDuty, cgLinkManUnitName, cgLinkManUnitAddress, cgLinkManUnitTelephone, cgLinkManUnitFacsimile, cgLinkManHomeAddress,
            cgLinkManHomeTelephone, cgLinkManHandset, cgLinkManEmail, cgLinkManQicq, cgLinkManMsn, cgLinkManRemark, curLoginUser.LoginName);
        Response.Redirect("CommunicationGroupLinkManShow.aspx?cgid=" + comGroupId);      
    }
    
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
    <link href="../CSS/TableStyle.css" rel="Stylesheet" />
    <script type="text/javascript" src="../../js/UserCommunication.js"></script>
       <link rel="Stylesheet" type="text/css" href="../../Styles/right_style.css" />
    <script type="text/javascript" src="../../Scripts/jquery.ui/js/jquery.js"></script>
    <script type="text/javascript" src="../../Scripts/My97DatePicker/WdatePicker.js"></script>

    <style type="text/css">
<!--
html{ scrollbar-base-color: #dbecf8; scrollbar-arrow-color: #2a8ed1; scrollbar-track-color: #bdddf2; scrollbar-3dlight-color: #2886c5; scrollbar-darkshadow-color: #2886c5;
scrollbar-face-color: #dbecf8; scrollbar-shadow-color: #dbecf8;  }
-->
</style>

</head>
<body>
    <form id="form1" runat="server">
    <div class="sub_right_top">
    <div class="add_book_guanli1" align="left">新建联系人</div>
            <table width="97%" border="1" cellpadding="0" cellspacing="0" bordercolor="#72b0d8" style="border-collapse:collapse; ">
          <tr bgcolor="#b1d5ef">
            <td colspan="2"><strong>分组</strong></td>

          </tr>
          
          <tr>
            <td width="170">分组：</td>
            <td width="597">
              <asp:DropDownList ID="DdlGroup" runat="server" Width="140">
                    </asp:DropDownList>
            </td>
          </tr>
          <tr bgcolor="#b1d5ef">
            <td colspan="2"><strong>个人信息</strong></td>
          </tr>
          <tr>
            <td width="170">姓名：</td>

            <td>
             <asp:TextBox ID="TxtName" runat="server"></asp:TextBox>
            </td>
          </tr>
          <tr>
            <td width="170">性别：</td>
            <td>
              <asp:DropDownList ID="DropDownList2" runat="server" Width="140px">
                        <asp:ListItem Value="0">男</asp:ListItem>
                        <asp:ListItem Value="1">女</asp:ListItem>
                    </asp:DropDownList>
            </td>
          </tr>
          <tr>
            <td width="170">生日：</td>

            <td>
              <asp:TextBox ID="TxtBirthday" runat="server" CssClass="Wdate" onClick="WdatePicker()"></asp:TextBox>
            </td>
          </tr>
          <tr>
            <td width="170">昵称：</td>
            <td>
              <asp:TextBox ID="TxtName2" runat="server"></asp:TextBox>

            </td>
          </tr>
          <tr>
            <td width="170">职务：</td>
            <td>
              <asp:TextBox ID="TxtDuty" runat="server"></asp:TextBox>
            </td>
          </tr>

          <tr bgcolor="#b1d5ef">
            <td colspan="2"><strong>联系方式(单位)</strong></td>
          </tr>
          <tr>
            <td width="170">单位名称：</td>
            <td>
             <asp:TextBox ID="TxtUnitName" runat="server"></asp:TextBox>
            </td>

          </tr>
          <tr>
            <td width="170">单位地址：</td>
            <td>
              <asp:TextBox ID="TxtUnitAddress" runat="server"></asp:TextBox>
            </td>
          </tr>
          <tr>

            <td width="170">单位电话：</td>
            <td>
              <asp:TextBox ID="TxtUnitTelephone" runat="server"></asp:TextBox>
            </td>
          </tr>
          <tr>
            <td width="170">单位传真：</td>
            <td>
            <asp:TextBox ID="TxtUnitFacsimile" runat="server"></asp:TextBox>
            </td>
          </tr>
          <tr bgcolor="#b1d5ef">
            <td colspan="2"><strong>联系方式(家庭)</strong></td>
          </tr>
          <tr>
            <td width="170">家庭住址：</td>

            <td>
              <asp:TextBox ID="TxtFamilyAddress" runat="server"></asp:TextBox>
            </td>
          </tr>
          <tr>
            <td width="170">家庭电话：</td>
            <td>
              <asp:TextBox ID="TxtFamilyTelephone" runat="server"></asp:TextBox>
            </td>
          </tr>
          <tr>
            <td width="170">手机：</td>
            <td>
              <asp:TextBox ID="TxtHandset" runat="server"></asp:TextBox>
            </td>
          </tr>

          <tr>
            <td width="170">电子邮件：</td>
            <td>
              <asp:TextBox ID="TxtEmail" runat="server"></asp:TextBox>
            </td>
          </tr>
          <tr>
            <td width="170">QQ号码：</td>

            <td>
              <asp:TextBox ID="TxtOicq" runat="server"></asp:TextBox>
            </td>
          </tr>
          <tr>
            <td width="170">MSN号码：</td>
            <td>
              <asp:TextBox ID="TxtMSN" runat="server"></asp:TextBox>

            </td>
          </tr>
          <tr bgcolor="#b1d5ef">
            <td colspan="2"><strong>备注</strong></td>
          </tr>
          <tr>
            <td colspan="2">
              <asp:TextBox ID="TxtRemark" runat="server" Width="100%" Height="97px" TextMode="MultiLine"
                       ></asp:TextBox>
            </td>
          </tr>
          <tr>
            <td colspan="2"><div class="disk_queding_top">
            <asp:Button ID="BtnAppend" runat="server" OnClick="BtnAppend_Click" OnClientClick="return checkCreateLinkMan('TxtName')"
                        Text="" CssClass="queding_anniu"/>
            </div>
          <div class="disk_back_top">
            <input id="Button1" onclick="window.history.go(-1)" style="width: 72px; height: 24px"
                        type="button" value=""  class="fanhui_anniu"/></div>
             <div class="clear"></div>            
      </td>
          </tr>
        </table>

    </div>
    </form>
</body>
</html>
